<form action = "{:url('editDict')}" style = "padding:12px;" method = "post" class = "layui-form ajax">
    <input type = "hidden" name = "dict_value" value = "{:input('dv')}"/>
    <table class="layui-table">
        <thead>
            <tr>
                <th ><center>名称</center></th>
                <th><center>名称值</center></th>
                <th><center>排序</center></th>
                <th><center>操作</center></th>
            </tr>
        </thead>
        <tbody id = "dict_data_body">
        {volist name="records" id="vo" key='k'}
            <tr>
                <td>
                    <input type="hidden" name="dict_data[{$k}][dict_value]" value = "{$vo.dict_value}"/>
                    <input type="hidden" class="form-control"  name="dict_data[{$k}][id]" id="dict_data[{$k}][id]" value = "{$vo.id}"/>
                    <div class="layui-form-item">
                        <input type="text" class="layui-input" placeholder="请输入名称" name="dict_data[{$k}][dict_data_name]" id="dict_data[{$k}][dict_data_name]" value = "{$vo.dict_data_name}"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" class="layui-input" placeholder="请输入名称值" name="dict_data[{$k}][dict_data_value]" id="dict_data[{$k}][dict_data_value]" value = "{$vo.dict_data_value}"/>
                    </div>
                </td>
                <td>
                    <div class="layui-form-item">
                        <input type="text" class="layui-input" placeholder="请输入排序" name="dict_data[{$k}][sort]" id="dict_data[{$k}][sort]" value = "{$vo.sort}"/>
                    </div>
                </td>
                <td>
                    <i class="layui-icon layui-icon-delete" onclick='del(this)'></i>
                </td>
            <tr>
        {/volist}
        </tbody>
    </table>
    <div class="layui-form-item" style = "text-align:center;">
        <button class = "layui-btn layui-btn-success" onclick = "add()" type = "button">新增</button>
        <button class = "layui-btn layui-btn-primary" type = "submit">保存</button>
    </div>
 </form>


<!-- bootstrap datepicker -->
<!-- bootstrap datepicker -->

<script>
    var currentCount = {:count($records)};
    function add(){
        currentCount++;
        var html = '<tr>'
            +'<td>'
            +	'<div class="layui-form-item">'
            +           '<input type = "hidden" name = "dict_data[' + currentCount + '][dict_value]" value = "{:input(\'dv\')}"/>'
            +			'<input type="text" class="layui-input" placeholder="请输入名称" name="dict_data['+ currentCount +'][dict_data_name]" id="dict_data['+ currentCount +'][dict_data_name]" />'
            +	'</div>'
            +'</td>'
            +'<td>'
            +	'<div class="layui-form-item">'
            +	    '<input type="text" class="layui-input" placeholder="请输入名称值" name="dict_data['+ currentCount +'][dict_data_value]" id="dict_data['+ currentCount +'][dict_data_value]" />'
            +	'</div>'
            +'</td>'
            +'<td>'
            +	'<div class="layui-form-item">'
            +	    '<input type="text" class="layui-input" placeholder="请输入排序" name="dict_data['+ currentCount +'][sort]" id="dict_data['+ currentCount +'][sort]" />'
            +	'</div>'
            +'</td>'
            +'<td>'
            +	'<i onclick="del(this)" class="layui-icon layui-icon-delete"></i>'
            +'</td>'
            +'<tr>';
        $("#dict_data_body").append(html);

    }
    function save(){
        $("form").submit();
    }
    function del(obj){
        var tr = $(obj);
        tr.parent().parent().remove();
    }
</script>
